home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-01 | 13.1 KB | 462 lines | [TEXT/MPS ] |
- ;
- ; File: Unicode.a
- ;
- ; Contains: Unicode Interfaces.
- ;
- ; Version: Technology: System 7.1 through System 8
- ; Release: Universal Interfaces 3.0d3 on Copland DR1
- ;
- ; Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
- ;
- ; Bugs?: If you find a problem with this file, send the file and version
- ; information (from above) and the problem description to:
- ;
- ; Internet: apple.bugs@applelink.apple.com
- ; AppleLink: APPLE.BUGS
- ;
- ;
- IF &TYPE('__UNICODE__') = 'UNDEFINED' THEN
- __UNICODE__ SET 1
-
- IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
- include 'Types.a'
- ENDIF
- IF &TYPE('__TEXTCOMMON__') = 'UNDEFINED' THEN
- include 'TextCommon.a'
- ENDIF
- IF &TYPE('__MIXEDMODE__') = 'UNDEFINED' THEN
- include 'MixedMode.a'
- ENDIF
- IF 0 THEN
- ;
- ; The following 7 typedefs are required for seeds until they get
- ; moved to a future version of Types.[hp] in a future ETO release.
- ; Also note that seeds should include a copy of the new TextCommon.[hp].
- ;
- ; typedef UInt8 * BytePtr
-
- ; typedef UInt32 ByteCount
-
- ; typedef UInt32 ItemCount
-
- ; typedef UInt32 OptionBits
-
- ; typedef short RegionCode
-
- ; typedef UInt32 ByteOffset
-
- ;
- ; The following typedefs are required for seeds until they get
- ; moved to a future version of Errors.[hp] in a future ETO release.
- ; Unicode Converter Error Codes
- ;
-
- unicodeChecksumErr EQU -8769
- unicodeNoTableErr EQU -8768
- unicodeVariantErr EQU -8767
- unicodeFallbacksErr EQU -8766
- unicodePartConvertErr EQU -8765
- unicodeBufErr EQU -8764
- unicodeCharErr EQU -8763
- unicodeElementErr EQU -8762
- unicodeNotFoundErr EQU -8761
- unicodeTableFormatErr EQU -8760
- unicodeDirectionErr EQU -8759
- unicodeContextualErr EQU -8758
- unicodeTextEncodingDataErr EQU -8757
- ENDIF
- IF FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE THEN
- ; Unicode Converter Gestalt Constants: (••••these belong in Gestalt.i••••)
-
- gestaltUnicodeAttr EQU 'unic'
- gestaltUnicodeConverterPresent EQU 0
- gestaltUnicodeConverterMask EQU $00000001
- ; Basic types for Unicode characters and strings:
- ; typedef UniChar * UniCharArrayPtr
-
- ; typedef const UniChar * ConstUniCharArrayPtr
-
- ; Unicode conversion contexts:
-
-
-
-
-
-
- ; UnicodeMapVersion type & values
- ; typedef SInt32 UnicodeMapVersion
-
-
- kUnicodeUseLatestMapping EQU -1
- ; Types used in conversion
- UnicodeMapping RECORD 0
- unicodeEncoding ds.l 1 ; offset: $0 (0)
- otherEncoding ds.l 1 ; offset: $4 (4)
- mappingVersion ds.l 1 ; offset: $8 (8)
- sizeof EQU * ; size: $C (12)
- ENDR
- ; typedef struct UnicodeMapping * UnicodeMappingPtr
-
- ; typedef const struct UnicodeMapping * ConstUnicodeMappingPtr
-
- TextEncodingRun RECORD 0
- offset ds.l 1 ; offset: $0 (0)
- textEncoding ds.l 1 ; offset: $4 (4)
- sizeof EQU * ; size: $8 (8)
- ENDR
- ; Control flags for ConvertUnicodeToText and ConvertTextToUnicode
-
- kUnicodeUseFallbacksBit EQU 0
- kUnicodeKeepInfoBit EQU 1
- kUnicodeDirectionalityBits EQU 2
- kUnicodeVerticalFormBit EQU 4
- kUnicodeLooseMappingsBit EQU 5
- kUnicodeStringUnterminatedBit EQU 6
- kUnicodeTextRunBit EQU 7
- kUnicodeKeepSameEncodingBit EQU 8
-
- kUnicodeUseFallbacksMask EQU $00000001
- kUnicodeKeepInfoMask EQU $00000002
- kUnicodeDirectionalityMask EQU $0000000C
- kUnicodeVerticalFormMask EQU $00000010
- kUnicodeLooseMappingsMask EQU $00000020
- kUnicodeStringUnterminatedMask EQU $00000040
- kUnicodeTextRunMask EQU $00000080
- kUnicodeKeepSameEncodingMask EQU $00000100
- ; Values for kUnicodeDirectionality field
-
- kUnicodeDefaultDirection EQU 0
- kUnicodeLeftToRight EQU 1
- kUnicodeRightToLeft EQU 2
- ; Control flags for TruncateForUnicodeToText:
-
- kUnicodeTextElementSafeBit EQU 0
- kUnicodeRestartSafeBit EQU 1
-
- kUnicodeTextElementSafeMask EQU $00000001
- kUnicodeRestartSafeMask EQU $00000002
- ; Filter bits for QueryUnicodeMappings filter field:
-
- kUnicodeMatchUnicodeBaseBit EQU 0
- kUnicodeMatchUnicodeVariantBit EQU 1
- kUnicodeMatchUnicodeFormatBit EQU 2
- kUnicodeMatchOtherBaseBit EQU 3
- kUnicodeMatchOtherVariantBit EQU 4
- kUnicodeMatchOtherFormatBit EQU 5
-
- kUnicodeMatchUnicodeBaseMask EQU $00000001
- kUnicodeMatchUnicodeVariantMask EQU $00000002
- kUnicodeMatchUnicodeFormatMask EQU $00000004
- kUnicodeMatchOtherBaseMask EQU $00000008
- kUnicodeMatchOtherVariantMask EQU $00000010
- kUnicodeMatchOtherFormatMask EQU $00000020
- ; Control flags for SetFallbackUnicodeToText
-
- kUnicodeFallbackSequencingBits EQU 0
-
- kUnicodeFallbackSequencingMask EQU $00000003
- ; values for kUnicodeFallbackSequencing field
-
- kUnicodeFallbackDefaultOnly EQU 0
- kUnicodeFallbackCustomOnly EQU 1
- kUnicodeFallbackDefaultFirst EQU 2
- kUnicodeFallbackCustomFirst EQU 3
- ENDIF
- IF FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE THEN
- ; Caller-supplied entry point to a fallback handler
- ENDIF
- IF FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE THEN
- ; Function prototypes
- ;
- ; The following are in TextCommon.i:
- ; CreateTextEncoding, GetTextEncodingBase, GetTextEncodingVariant, GetTextEncodingFormat
- ;
- ; Create a new TextToUnicodeInfo structure.
- ;
- ; pascal OSStatus CreateTextToUnicodeInfo(ConstUnicodeMappingPtr UnicodeMapping, TextToUnicodeInfo *textToUnicodeInfo)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _CreateTextToUnicodeInfo
- move.w #$0401,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION CreateTextToUnicodeInfo
- ENDIF
-
- ; Create a new UnicodeToTextInfo structure.
- ;
- ; pascal OSStatus CreateUnicodeToTextInfo(ConstUnicodeMappingPtr UnicodeMapping, UnicodeToTextInfo *unicodeToTextInfo)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _CreateUnicodeToTextInfo
- move.w #$040C,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION CreateUnicodeToTextInfo
- ENDIF
-
- ;
- ; pascal OSStatus CreateUnicodeToTextRunInfo(ItemCount numberOfMappings, ConstUnicodeMappingPtr UnicodeMapping, UnicodeToTextRunInfo *unicodeToTextInfo)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _CreateUnicodeToTextRunInfo
- move.w #$0612,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION CreateUnicodeToTextRunInfo
- ENDIF
-
- ; Dispose of a TextToUnicodeInfo structure.
- ;
- ; pascal OSStatus DisposeTextToUnicodeInfo(TextToUnicodeInfo *textToUnicodeInfo)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _DisposeTextToUnicodeInfo
- move.w #$0202,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION DisposeTextToUnicodeInfo
- ENDIF
-
- ; Dispose of a UnicodeToTextInfo structure.
- ;
- ; pascal OSStatus DisposeUnicodeToTextInfo(UnicodeToTextInfo *unicodeToTextInfo)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _DisposeUnicodeToTextInfo
- move.w #$020D,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION DisposeUnicodeToTextInfo
- ENDIF
-
- ;
- ; pascal OSStatus DisposeUnicodeToTextRunInfo(UnicodeToTextRunInfo *unicodeToTextInfo)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _DisposeUnicodeToTextRunInfo
- move.w #$0213,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION DisposeUnicodeToTextRunInfo
- ENDIF
-
- ; Convert a string to Unicode.
- ;
- ; pascal OSStatus ConvertTextToUnicode(TextToUnicodeInfo textToUnicodeInfo, ByteCount sourceLen, ConstLogicalAddress sourceStr, OptionBits controlFlags, ItemCount offsetCount, ByteOffset *offsetArray, ByteCount bufLen, ByteCount *sourceRead, ByteCount *unicodeLen, UniCharArrayPtr unicodeStr)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ConvertTextToUnicode
- move.w #$1404,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ConvertTextToUnicode
- ENDIF
-
- ; Convert a string from Unicode.
- ;
- ; pascal OSStatus ConvertUnicodeToText(UnicodeToTextInfo unicodeToTextInfo, ByteCount unicodeLen, ConstUniCharArrayPtr unicodeStr, OptionBits controlFlags, ItemCount offsetCount, ByteOffset *offsetArray, ByteCount bufLen, ByteCount *inputRead, ByteCount *outputLen, LogicalAddress outputStr)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ConvertUnicodeToText
- move.w #$1403,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ConvertUnicodeToText
- ENDIF
-
- ;
- ; pascal OSStatus ConvertUnicodeToTextRun(UnicodeToTextRunInfo unicodeToTextInfo, ByteCount unicodeLen, ConstUniCharArrayPtr unicodeStr, OptionBits controlFlags, ItemCount offsetCount, ByteOffset *offsetArray, ByteCount bufLen, ByteCount *inputRead, ByteCount *outputLen, LogicalAddress outputStr, ItemCount encodingRunBufLen, ItemCount *encodingRunOutLen, TextEncodingRun *encodingRuns)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ConvertUnicodeToTextRun
- move.w #$1A14,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ConvertUnicodeToTextRun
- ENDIF
-
- ; Truncate a multibyte string at a safe place.
- ;
- ; pascal OSStatus TruncateForTextToUnicode(ConstTextToUnicodeInfo textToUnicodeInfo, ByteCount sourceLen, ConstLogicalAddress sourceStr, ByteCount maxLen, ByteCount *truncatedLen)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _TruncateForTextToUnicode
- move.w #$0A06,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION TruncateForTextToUnicode
- ENDIF
-
- ; Truncate a Unicode string at a safe place.
- ;
- ; pascal OSStatus TruncateForUnicodeToText(ConstUnicodeToTextInfo unicodeToTextInfo, ByteCount sourceLen, ConstUniCharArrayPtr sourceStr, OptionBits controlFlags, ByteCount maxLen, ByteCount *truncatedLen)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _TruncateForUnicodeToText
- move.w #$0C05,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION TruncateForUnicodeToText
- ENDIF
-
- ; Convert a Pascal string to Unicode.
- ;
- ; pascal OSStatus ConvertPStringToUnicode(TextToUnicodeInfo textToUnicodeInfo, ConstStr255Param pascalStr, ByteCount bufLen, ByteCount *unicodeLen, UniCharArrayPtr unicodeStr)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ConvertPStringToUnicode
- move.w #$0A08,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ConvertPStringToUnicode
- ENDIF
-
- ; Convert a Unicode string to Pascal.
- ;
- ; pascal OSStatus ConvertUnicodeToPString(UnicodeToTextInfo unicodeToTextInfo, ByteCount unicodeLen, ConstUniCharArrayPtr unicodeStr, Str255 pascalStr)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ConvertUnicodeToPString
- move.w #$0807,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ConvertUnicodeToPString
- ENDIF
-
- ; Get a list of the available conversion mappings.
- ;
- ; pascal OSStatus QueryUnicodeMappings(OptionBits filter, ConstUnicodeMappingPtr findMapping, ItemCount maxCount, ItemCount *actualCount, UnicodeMappingPtr returnedMappings)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _QueryUnicodeMappings
- move.w #$0A09,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION QueryUnicodeMappings
- ENDIF
-
- ; Get the name of a TextEncodingBase table.
- ;
- ; pascal OSStatus GetTextEncodingBaseName(ConstUnicodeMappingPtr UnicodeMapping, LangCode languageID, ByteCount bufLen, ByteCount *nameLength, UniCharArrayPtr mappingName)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _GetTextEncodingBaseName
- move.w #$090A,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION GetTextEncodingBaseName
- ENDIF
-
- ; Change the TextToUnicodeInfo to another mapping.
- ;
- ; pascal OSStatus ChangeTextToUnicodeInfo(TextToUnicodeInfo textToUnicodeInfo, ConstUnicodeMappingPtr UnicodeMapping)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ChangeTextToUnicodeInfo
- move.w #$040B,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ChangeTextToUnicodeInfo
- ENDIF
-
- ; Change the UnicodeToTextInfo to another mapping.
- ;
- ; pascal OSStatus ChangeUnicodeToTextInfo(UnicodeToTextInfo unicodeToTextInfo, ConstUnicodeMappingPtr UnicodeMapping)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ChangeUnicodeToTextInfo
- move.w #$040E,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ChangeUnicodeToTextInfo
- ENDIF
-
- ENDIF
- IF FOR_SYSTEM8_PREEMPTIVE THEN
- ; Setup the fallback handler for converting Unicode To Text.
- ;
- ; pascal OSStatus SetFallbackUnicodeToTextPreemptive(UnicodeToTextInfo unicodeToTextInfo, UnicodeToTextFallbackPreemptiveProcPtr fallback, OptionBits controlFlags, LogicalAddress infoPtr)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION SetFallbackUnicodeToTextPreemptive
- ENDIF
-
- ;
- ; pascal OSStatus SetFallbackUnicodeToTextRunPreemptive(UnicodeToTextRunInfo unicodeToTextRunInfo, UnicodeToTextFallbackPreemptiveProcPtr fallback, OptionBits controlFlags, LogicalAddress infoPtr)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION SetFallbackUnicodeToTextRunPreemptive
- ENDIF
-
- ENDIF
- IF FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE THEN
- ; Setup the fallback handler for converting Unicode To Text.
- ;
- ; pascal OSStatus SetFallbackUnicodeToText(UnicodeToTextInfo unicodeToTextInfo, UnicodeToTextFallbackUPP fallback, OptionBits controlFlags, LogicalAddress infoPtr)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _SetFallbackUnicodeToText
- move.w #$080F,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION SetFallbackUnicodeToText
- ENDIF
-
- ;
- ; pascal OSStatus SetFallbackUnicodeToTextRun(UnicodeToTextRunInfo unicodeToTextRunInfo, UnicodeToTextFallbackUPP fallback, OptionBits controlFlags, LogicalAddress infoPtr)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _SetFallbackUnicodeToTextRun
- move.w #$0819,D0
- dc.w $ABCE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION SetFallbackUnicodeToTextRun
- ENDIF
-
- ;
- ; The following are in TextCommon.i:
- ; UpgradeScriptInfoToTextEncoding, RevertTextEncodingToScriptInfo
- ;
- ENDIF
- ENDIF ; __UNICODE__
-
-